-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Refactor attachment upload into a service #1547
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for this, the controller is much cleaner now! in addition to the suggestions in the comments, could you also help with the following:
- add generic type arguments to the
RequestHandler
type forhandleEncryptedSubmission
. this is because when we don't supply generic type arguments,req.body
is typed asany
, which means we lack type safety in the controller. you can look athandleEmailSubmission
for an example, and you can make use of the typeEncryptSubmissionBody
which is already defined inencrypt-submission.types.ts
. I think theattachments
key inEncryptSubmissionBody
might be typed wrongly because it's missing the field ID, so you may have to fix that. - avoid using
res.locals
within the controller, as everything inres.locals
is typed asany
by default as well. we can just use local variables within the controller.
src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, at the v2/submissions/encrypt endpoint (where handleEncryptedSubmission
is called), we are calling forms.formById
an extra time - could you remove that pls?
src/app/modules/submission/encrypt-submission/encrypt-submission.controller.ts
Outdated
Show resolved
Hide resolved
@mantariksh made changes based on your comments, PTAL again, thanks! |
@frankchn thanks for the latest changes! could you also help with the following please:
|
@mantariksh Should I do this in another PR? The other refactorings are not really part of this PR and I don't really think should be rolled into this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@frankchn sure, we can incorporate those changes in another PR. the code looks good other than a minor point on logging as well as merge conflicts (which should be easy to resolve).
src/app/modules/submission/encrypt-submission/encrypt-submission.service.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm other than merge conflicts!
Problem
Part of the set of pull requests that addresses #149
Solution
Refactor upload attachments to its own attachments service.